package com.flute.search.util;

import java.io.IOException;
import java.io.Writer;

import com.thoughtworks.xstream.core.util.QuickWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.XmlFriendlyReplacer;
import com.thoughtworks.xstream.io.xml.XppDriver;

public class MyXppDriver extends XppDriver {
	public HierarchicalStreamWriter createWriter(Writer out) {
        try {
			out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".toCharArray());
		} catch(IOException e) {
			e.printStackTrace();
		}
    	return new PrettyPrintWriter(out,new XmlFriendlyReplacer(
						"_-", "_")) {
            protected void writeText(QuickWriter writer, String text) {
                writer.write("<![CDATA[");
                writer.write(text);
                writer.write("]]>");
            }
        };
    } 
}
